package cn.xaut.周赛.m226;

import java.util.*;

public class demo1742 {

    public static int countBalls(int lowLimit, int highLimit) {

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = lowLimit; i <= highLimit; i++) {
            int sum = 0, x = i;
            while (x != 0) {
                sum += x % 10;
                x /= 10;
            }
            if (map.containsKey(sum))
                map.put(sum, map.get(sum) + 1);
            else
                map.put(sum, 1);
        }
        int max = Integer.MIN_VALUE;
        for (int a : map.values()) {
            if (a > max)
                max = a;
        }
        return max;
    }
    
    public static void main(String[] args) {

        System.out.println(countBalls(1, 10));
        System.out.println(countBalls(5, 15));
        System.out.println(countBalls(19, 28));
    }
}
